********************************************************************************
*REPLICATION MATERIAL FOR Rudolph, L., T. D�ubler (2016) "Holding Individual Representatives Accountable: The Role of Electoral Systems", The Journal of Politics, forthcoming.
********************************************************************************

********************************************************************************
*This Do-File replicates the results presented in Tables 1 and 2 of the main text and in Tables A2, A3, A5, A6, A9 and A12 of the Online Appendix (SMD-Level and Difference-in-Tiers)
********************************************************************************

version 13
set more off
clear all

/* install estout-package by Ben Jann in Version st0085_2 (Stata Journal 14-2) via "findit st0085_2".
		st0085_2 from http://www.stata-journal.com/software/sj14-2
		SJ14-2 st0085_2. Update: Making regression... / Update: Making regression
		tables from stored / estimates / by Ben Jann, University of Bern */

*set working directory to folder containing replication data files main folder 

cd ""

capture log close
log using tables\replication_SMD.log, replace


********************************************************************************
*Table 1: Effects of Scandal Involvement on the Trend in CSU First Vote Shares
********************************************************************************

use tables\aggregate_treat.dta, clear

xtset nr year
fvset base 2008 year

global c = "population employment_share immigrant_share influx  buildings farmers pc_tax pc_debt" // candidate level controls
global g = "incumbency leg local_committee kabinett bezirksvorsitz01 parteiamt affair_noncsu opp_leader danube13" // district level controls

eststo clear

quietly eststo mod1: xtreg csu_fv affair i.year##i.region2 $c $g i.year if year>=2008, cluster(nr) fe 
quietly eststo mod2: xtreg csu_fv affair_cont  i.year##i.region2 i.year $c $g if year>=2008, cluster(nr) fe 
quietly eststo mod3: xtreg csu_fv affair_run affair_norun  i.year##i.region2 i.year $c $g if year>=2008, cluster(nr) fe 
quietly eststo mod4: xtreg csu_fv affair_run_cont affair_norun_cont  i.year##i.region2 i.year $c $g if year>=2008, cluster(nr) fe 

sum csu_fv if affair==0 & year==2013
estadd scalar control_mean2013 = r(mean) : mod1 mod2 mod3 mod4

esttab mod1 mod2 mod3 mod4, replace compress stats(N control_mean2013) b(2) se(2) star(* 0.05) label indicate("Candidate and district controls = $c $g danube13 " "Regional trends = *region*") order(*affair* danube* *year* $c) drop( *2008.year*) ///
rename(affair_cont affair affair_norun_cont affair_norun affair_run_cont affair_run) /// 
title(Table 1: Effects of Scandal Involvement on the Trend in CSU First Vote Shares) ///
note("Fixed-effects regression on 2008-2013 CSU first vote shares with robust standard errors, clustered by district, in parentheses. The treatment indicator is binary (Models 1, 3) or continuous (Models 2, 4). We observe 23 implicated districts, of which 14 are with Բunning affair MPsԮ Control variables included are population density (in 1000s), share of employed population (subject to social insurance contributions), immigrant share, in-migration (in 1000s), building completions (in 1000s), farms (in 1000s), per capita communal tax (in Euro), per capita communal debt (in Euro), CSU candidate member of parliament, number of legislative periods of candidate, candidate local committee member, candidate member of government, candidate regional party leader, candidate leading party functionary, opposition party leader in district, affair of opposition candidate, major damage of 2013 June flood in district. Regressions allow for separate regional trends in northern Bavaria.") ///
mtitles("binary treat." "cont. treat." "binary treat." "cont. treat.") ///
collabels("First vote",lhs(Dep. var.: CSU vote shares))


************************************************************************************************************************
*Table 2: Effects of Scandal Involvement on the 2013 Differences of CSU First and Second Vote Shares (Diff-in-Tiers)
************************************************************************************************************************

use tables\aggregate_treat.dta, clear

fvset base 2008 year
fvset base 0 leg

global h = "incumbency leg danube13 local_committee kabinett bezirksvorsitz01 parteiamt  affair_noncsu opp_leader cand_female titel cand_age indiff2010" 

eststo clear

quietly eststo mod1: reg diff_tiers affair_run   $h  i.region   if year>=2013 & inc == 1,  r
quietly eststo mod2: reg diff_tiers affair_run   $h  i.region   if year>=2013 ,  r
quietly eststo mod3: reg diff_tiers c.affair_run_cont  $h  i.region  if year>=2013 & inc == 1,  r
quietly eststo mod4: reg diff_tiers c.affair_run_cont  $h  i.region  if year>=2013 ,  r

esttab mod* , append b(2) se(2) star(* 0.05) label compress  order(*affair*  danube* ) indicate( "Controls for candidate quality and indifference= *leg* cand_female titel incumbency* $h" "Controls for region = *region*" ) ///
rename(affair_run_cont affair_run) /// 
title("Table 2: Effects of Scandal Involvement on the 2013 Differences of CSU First and Second Vote Shares") ///
note("Note: Regression of 2013 difference of first and second vote share of CSU (at district level), with robust standard errors in parentheses. For Model 1 and 3, sample draws on 2013 incumbents only. The treatment indicator is binary (Models 1, 2) or continuous (Models 3, 4). We observe 14 districts with Բunning affair MPsԮ Control variables for candidate quality include CSU candidate member of local committee, cabinet member, regional party leader, leading party functionary, opposition party leader in district, affair of opposition candidate, major damage of 2013 June flood in district, age (in years), dummies for female, academic title and a measure for district level aggregate indifference. Regressions as well include dummies for the OLPR districts (regions) in Bavaria.") ///
mtitles("binary treat." "binary treat." "cont. treat." "cont. treat.") ///
collabels("Diff-in-tiers",lhs(Dep. var.: Diff. in CSU first and second vote sh.))



************************************************************************************************************************
*Online Appendix: Table A2: Placebo Effects of Scandal Involvement on the Pre-Treatment Effect/Trend in CSU First Vote Shares/ Difference-in-Tiers
************************************************************************************************************************

use tables\aggregate_placebo.dta

xtset nr year, delta(5)
fvset base 2003 year

eststo clear

quietly eststo: xtreg csu_fv f_affair  i.year, cluster(nr) fe
quietly eststo: xtreg csu_fv f_affair  i.year##i.region2, cluster(nr) fe
quietly eststo: xtreg csu_fv f_affair_run f_affair_norun  i.year, cluster(nr) fe
quietly eststo: xtreg csu_fv f_affair_run f_affair_norun  i.year##i.region2, cluster(nr) fe
quietly eststo: reg diff_tiers f_affair_run  if year==2008 & inc2==1 , r
quietly eststo: xtreg diff_tiers f_affair_run  i.year if inc==1 , cluster(nr) fe
quietly eststo: xtreg diff_tiers f_affair_run  i.year##i.region if inc==1 , cluster(nr) fe

esttab , compress b(2) se(2) star(* 0.05) order(*affair*)  drop(2003.year) label indicate("Regional trends = *region*") /// 
title("Table A2: Placebo Effects of Scandal Involvement on the Pre-Treatment Effect/Trend in CSU First Vote Shares/Difference-in-Tiers") ///
note("Note: Model 1-4, 6-7: Fixed-effects regression on 2003-2008 CSU vote shares (Model 1 to 4 with dependent variable first vote share and Model 6 and 7 with difference in first and second vote shares) with robust standard errors, clustered by district, in parentheses. Model 6 and 7 draw on 2008 incumbents that ran in 2003 as well. Regressions that allow for separate regional trends in northern Bavaria/OLPR districts (Model 7) are indicated. Model 5: OLS regression with robust standard errors on the difference in 2008 CSU first and second vote shares in districts with 2013 incumbents only.") ///
collabels("" ,lhs(Dep. var.: CSU vote shares))


************************************************************************************************************************
*Online Appendix: Table A3: 2013 Summary Statistics for District Level Controls
************************************************************************************************************************
use tables\aggregate_treat.dta, clear

tab region, gen(region_dum)

eststo clear
eststo allcand: estpost ttest population employment_share immigrant_share influx  buildings farmers pc_tax pc_debt incumbency danube  opp_leader affair_noncsu local_committee kabinett leg bezirksvorsitz01 parteiamt indiff2010  region_dum1 if year==2013, by(affair) 
eststo running: estpost ttest population employment_share immigrant_share influx  buildings farmers pc_tax pc_debt incumbency danube  opp_leader affair_noncsu local_committee kabinett leg bezirksvorsitz01 parteiamt indiff2010  region_dum1 if year==2013, by(affair_run) 

esttab allcand running, label compress star(* 0.05 ) /// 
cells("mu_1(fmt(%12.2f) label(Control)) mu_2(fmt(%12.2f) label(Treated)) b(fmt(%12.2f) star label(Diff-In-2013-Means))" "mean mean se(par fmt(2))" ". . .") ///
title("2013 Summary Statistics for District Level and Candidate Quality Controls") ///
note("Note: Comparison of 2013 DID control variables (mean and mean difference with standard errors in parantheses) for all affair districts vs. rest (columns 1-3) and running affair candidate districts vs. rest (columns 4-6).")


************************************************************************************************************************
*Online Appendix: Table A5: Effects of Scandal Involvement on the Trend in CSU First Vote Shares - Display of All Coefficients of Table 1 and Additional Models
************************************************************************************************************************

use tables\aggregate_treat.dta, clear

xtset nr year
fvset base 2008 year

eststo clear

quietly eststo app1: xtreg csu_fv affair  i.year if year>=2008, cluster(nr) fe
quietly eststo app2: xtreg csu_fv affair i.year $c $g danube13 i.year if year>=2008, cluster(nr) fe 
quietly eststo mod1: xtreg csu_fv affair i.year##i.region2 $c $g danube13 i.year if year>=2008, cluster(nr) fe 
quietly eststo mod2: xtreg csu_fv affair_cont  i.year##i.region2 i.year $c $g danube13 if year>=2008, cluster(nr) fe 
quietly eststo mod3: xtreg csu_fv affair_run affair_norun  i.year##i.region2 i.year $c $g danube13 if year>=2008, cluster(nr) fe 
quietly eststo mod4: xtreg csu_fv affair_run_cont affair_norun_cont  i.year##i.region2 i.year $c $g danube13 if year>=2008, cluster(nr) fe 

sum csu_fv if affair==0 & year==2013
estadd scalar control_mean2013 = r(mean) : app1 app2 mod1 mod2 mod3 mod4

esttab mod1 mod2 mod3 mod4 app* , append compress stats(N control_mean2013) b(2) se(2) star(* 0.05)  label order(affair affair_run affair_norun danube13 $c $g *year*) drop(2008.*  ?.region2 2013.year#1.region2) ///
rename(affair_cont affair affair_norun_cont affair_norun affair_run_cont affair_run) /// 
title(Table A5: Effects of Scandal Involvement on the Trend in CSU First Vote Shares - Display of All Coefficients of Table X and Additional Models) ///
note("Fixed-effects regression on 2008-2013 CSU first vote shares with robust standard errors, clustered by district, in parentheses. The treatment indicator is binary (Models 1, 3) or continuous (Models 2, 4). We observe 23 implicated districts, of which 14 are with Բunning affair MPsԮ Control variables included are population density (in 1000s), share of employed population (subject to social insurance contributions), immigrant share, in-migration (in 1000s), building completions (in 1000s), farms (in 1000s), per capita communal tax (in Euro), per capita communal debt (in Euro), CSU candidate member of parliament, number of legislative periods of candidate, candidate local committee member, candidate member of government, candidate regional party leader, candidate leading party functionary, opposition party leader in district, affair of opposition candidate, major damage of 2013 June flood in district. Regressions allow for separate regional trends in northern Bavaria.") ///
mtitles("binary treat." "cont. treat." "binary treat." "cont. treat." "binary treat." "binary treat.") ///
collabels("First vote",lhs(Dep. var.: CSU vote shares))


************************************************************************************************************************
*Online Appendix: Table A6: Effects of Scandal Involvement on the 2013 Differences of CSU First and Second Vote Shares - Display of All Coefficients of Table 2 and Additional Models
************************************************************************************************************************
* diff-in-tiers, cross-sectional 

use tables\aggregate_treat.dta, clear

fvset base 2008 year
fvset base 0 leg

global c = "population employment_share immigrant_share influx  buildings farmers pc_tax pc_debt "
global h = "incumbency leg danube13 local_committee kabinett bezirksvorsitz01 parteiamt  affair_noncsu opp_leader  cand_female titel  cand_age indiff2010" 

eststo clear
quietly eststo app1: reg diff_tiers affair_run   $h  if year>=2013 & inc == 1 ,  r
quietly eststo tab1: reg diff_tiers affair_run   $h  i.region   if year>=2013 & inc == 1,  r
quietly eststo tab2: reg diff_tiers affair_run   $h  i.region   if year>=2013 ,  r
quietly eststo app2: reg diff_tiers c.affair_run_cont  $h  if year>=2013 & inc == 1,  r
quietly eststo tab3: reg diff_tiers c.affair_run_cont  $h  i.region  if year>=2013 & inc == 1,  r
quietly eststo tab4: reg diff_tiers c.affair_run_cont  $h  i.region  if year>=2013 ,  r

esttab tab1 tab2 tab3 tab4 app1 app2 , b(2) se(2) star(* 0.05) label compress drop(1.region) order(affair_run danube13 incumbency $h *female* *titel* *region*)  ///
rename(affair_run_cont affair_run) /// 
title("Table : Effects of Scandal Involvement on the 2013 Differences of CSU First and Second Vote Shares - Display of All Coefficients of Table X and Additional Models"}) ///
note("Note: regression on 2013 difference in first and second vote shares of CSU in districts with robust standard errors in parentheses. Sample draws on 2013 incumbents only for Model 1 and 3. The treatment indicator is binary (Models 1, 2) or continuous (Models 3, 4). We observe 14 districts with running affair MPs. Control variables for candidate quality include CSU candidate member of local committee, cabinet member, regional party leader, leading party functionary, opposition party leader in district, affair of opposition candidate, major damage of 2013 June flood in district, age (in years), dummies for female, academic title and a measure for district level aggregate indifference. Regressions as well include dummies for the OLPR districts (regions) in Bavaria.") ///
mtitles("binary treat." "binary treat." "cont. treat." "cont. treat." "binary treat." "cont. treat.") ///
collabels("Diff-in-tiers",lhs(Dep. var.: Dep. var.: Diff. in CSU first and second vote sh.))



************************************************************************************************************************
*Online Appendix: Table A9: Robustness Results of Table 1 - Effects of Scandal Involvement on the Trend in CSU First Vote Shares - Leave-one-out analysis on Model 1 of Table 1
************************************************************************************************************************

global c = "population employment_share immigrant_share influx  buildings farmers pc_tax pc_debt" // candidate level controls
global g = "incumbency leg local_committee kabinett bezirksvorsitz01 parteiamt affair_noncsu opp_leader danube13" // district level controls

*binary treatment, column 2 of Table A9

eststo clear

foreach v in 105 108 201 207 303  306  307  401  403  405  406  507  511  512  603  607  608  704  705  706  708  710  713  {
eststo without`v': quietly xtreg csu_fv affair i.year##i.region2 $c $g danube13 i.year if year>=2008 & nr!=`v', fe cluster(nr)
}

esttab, keep(affair) se nostar // thanks to Ben Jann: http://www.stata.com/statalist/archive/2009-01/msg01084.html
matrix C = r(coefs)
eststo clear
local rnames : rownames C
local models : coleq C
local models : list uniq models
local i 0
foreach name of local rnames {
    local ++i
    local j 0
    capture matrix drop b
    capture matrix drop se
    foreach model of local models {
        local ++j
        matrix tmp = C[`i', 2*`j'-1]
        if tmp[1,1]<. {
            matrix colnames tmp = `model'
            matrix b = nullmat(b), tmp
            matrix tmp[1,1] = C[`i', 2*`j']
            matrix se = nullmat(se), tmp
        }
    }
    ereturn post b
    quietly estadd matrix se
    eststo `name'
}

esttab, compress b(2) se(2) star(* 0.05)   ///
title({\b Table : Effects of Scandal Involvement on the Trend in CSU First Vote Shares - Leave-on-out analysis on Model 1 of Table X}) ///
note("Note: Fixed-effects regression on 2008-2013 CSU first vote shares with robust standard errors, clustered by district in parentheses. The treatment indicator is binary. The reported coefficients are treatment effects, each estimated from a different regression as indicated in the heading, dropping the district named in the respective row out of the analysis. N = 178 in all cases.") ///
collabels("First vote",lhs(Dep. var.: CSU vote shares))

*cont. treatment, column 2 of Table A9
eststo clear
foreach v in 105 108 201 207 303  306  307  401  403  405  406  507  511  512  603  607  608  704  705  706  708  710  713  {
eststo without`v': quietly xtreg csu_fv affair_cont i.year##i.region2 $c $g danube13 i.year if year>=2008 & nr!=`v', fe cluster(nr)
}

esttab, keep(affair_cont) se nostar // thanks to Ben Jann: http://www.stata.com/statalist/archive/2009-01/msg01084.html
matrix C = r(coefs)
eststo clear
local rnames : rownames C
local models : coleq C
local models : list uniq models
local i 0
foreach name of local rnames {
    local ++i
    local j 0
    capture matrix drop b
    capture matrix drop se
    foreach model of local models {
        local ++j
        matrix tmp = C[`i', 2*`j'-1]
        if tmp[1,1]<. {
            matrix colnames tmp = `model'
            matrix b = nullmat(b), tmp
            matrix tmp[1,1] = C[`i', 2*`j']
            matrix se = nullmat(se), tmp
        }
    }
    ereturn post b
    quietly estadd matrix se
    eststo `name'
}
esttab, compress b(2) se(2) star(* 0.05)   ///
title("Table : Effects of Scandal Involvement on the Trend in CSU First Vote Shares - Leave-on-out analysis on Model 2 of Table X") ///
note("Note: Fixed-effects regression on 2008-2013 CSU first vote shares with robust standard errors, clustered by district in parentheses. The treatment indicator is continouus. Each regression (horizontally) leaves the indicated treated district out of the analysis. N = 178 in all cases.") ///
collabels("First vote",lhs(Dep. var.: CSU vote shares))



************************************************************************************************************************
*Online Appendix: Table A10: Robustness of Table 3 - Impact of Affair on Ranking of Candidates within CSU Party Lists
************************************************************************************************************************
*diff-in-tiers, diff-in-diff 

global h = "danube13 local_committee kabinett bezirksvorsitz01 parteiamt affair_noncsu opp_leader"

eststo clear

quietly eststo: xtreg diff_tiers affair_run incumbency $h i.year##i.region if year>=2008 & inc2 == 1, fe cluster(nr)
quietly eststo: xtreg diff_tiers affair_run incumbency $h i.year##i.region  if year>=2008 , fe cluster(nr)
quietly eststo: xtreg diff_tiers affair_run_cont incumbency $h i.year##i.region if year>=2008 & inc2 == 1, fe cluster(nr)
quietly eststo: xtreg diff_tiers affair_run_cont incumbency $h i.year##i.region  if year>=2008 , fe cluster(nr)

quietly eststo: xtreg diff_tiers affair_run i.year##i.region if year>=2008 & inc2 == 1, fe cluster(nr)
quietly eststo: xtreg diff_tiers affair_run_cont i.year##i.region if year>=2008 & inc2 == 1, fe cluster(nr)
 
esttab, b(2) se(2) star(* 0.05) label compress drop(?.region 2008.year* 2013.year*1.region) order(affair_run 2013.year incumbency  $h  *region* *year* )  ///
rename(affair_run_cont affair_run) /// 
title({\b Table : Effects of Scandal Involvement on the 2008-2013 Trend in Differences of CSU First and Second Vote Shares}) ///
note("Note: Fixed-effects regression on CSU difference in first and second vote shares for the 2008-2013 period with robust standard errors, clustered by district, in parentheses. Sample draws on district incumbents in 2013 that ran as well in 2008 besides Models 2 and 4. The treatment indicator is binary (Models 1, 2, 5) or continuous (Models 3, 4, 6). We observe 14 districts with running �affair� MPs in 2013; one �affair� MP changed district and is therefore not contained in Models 1, 2, 5 (sample of 2013 district incumbents that ran as well in 2008). Control variables for candidate quality include CSU candidate member of local committee, cabinet member, regional party leader, leading party functionary, opposition party leader in district, affair of opposition candidate and major damage of 2013 June flood in district. Regressions as well allow for trends for the OLPR districts (regions) in Bavaria.") ///
mtitles("binary treat." "binary treat." "cont. treat." "cont. treat." "binary treat." "cont. treat.") ///
collabels("Diff-in-Diff-in-tiers",lhs(Dep. var.: Diff. in CSU first and second vote sh.))


*********************************************
*END
*********************************************

log close


